//
//  ProductApi.swift
//  Pods
//
//  Created by eme on 2017/3/24.
//
//


import Foundation
import Alamofire
import ModelProtocol
import NetWorkCore
import UtilCore

/*
 owner:cy
 update:2017年03月24日10:10:323
 info: 商品 api
 
 */
public enum ProductApi{
    ///新增商品收藏
    /*
     *json:usPdCollection=json#商品增加收藏
     {
     "cid": "112312312",
     "userid": "1",
     "pdid": "1"
     }
     */
    case addusPdCollection(userid:String,pdid:String)
    ///用户取消收藏商品（删除收藏的商品）
    case delusPdCollection(cid:String)
    
}
extension ProductApi: TargetType {
    
    //设置请求路径
    public var path: String {
        switch self {
        case .addusPdCollection:
            return "/usPdCollection/a/add.json"
        case .delusPdCollection:
            return "/usPdCollection/a/del.json"
        }
    }
    
    //设置请求方式 get post等
    public var method: HTTPMethod {
        switch self {
        default :
            return .post
            
        }
    }
    /// 设置请求参数
    public var parameters: Parameters? {
        switch self {
        case let .addusPdCollection(userid, pdid):
            let param: [String: String] = ["userid":userid,"pdid":pdid]
            return ["usPdCollection": JSONHelper.parseToJson(param as AnyObject) as String]
        case let .delusPdCollection(cid):
            return ["cid":cid,"page":0,"length":1]
        }
    }
    
}
